joystick object
This method returns an array containing the names of all connected and available joysticks on the user's system.
string[] list_joysticks()
Parameters:
None.
Return value:
An array containing the names of all available joysticks on success, or an empty list on failure or if no joysticks are available.
Remarks:
The entries in this list are useful if you wish to give the user a choice as to what joystick that should be used. You may use an index in this list when calling the set method to activate a given joystick.
Please note that the contents of this list are retrieved from a cache, as opposed to being reenumerated each time this method is called. This is to prevent joystick ID's from being invalidated if the user should plug out an existing joystick or plug in a new one during the execution of your game. To refresh this list, call the refresh_joystick_list method.
Example:
// Enumerate the list of joysticks and display information on them.
void main()
{
joystick stick;
show_game_window("Joystick Test");
if(stick.joysticks==0)
{
alert("Error", "No joysticks seem to be attached.");
exit();
}
string[] names=stick.list_joysticks();
for(int i=0;i<names.length();i++)
{
alert("Joystick " + (i+1), names[i]);
stick.set(i);
if(stick.active==false)
{
alert("Error", "Could not open the joystick device.");
continue;
}
alert("Information", "Buttons: " + stick.buttons + "\nSliders: " + stick.sliders + "\nPovs: " + stick.povs);
}
}